package com.smart.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.smart.model.domain.SuperviseUserDO;
import com.smart.model.request.SuperviseUserRequest;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author zhanghong
 */
@Repository
public interface SuperviseUserMapper extends BaseMapper<SuperviseUserDO> {
    SuperviseUserDO selectDOById(Long id);
    List<SuperviseUserDO> selectDOList(SuperviseUserDO superviseUser);
    int insertDO(SuperviseUserDO superviseUser);
    int batchInsertDO(List<SuperviseUserDO> superviseUserDOList);
    int updateDO(SuperviseUserDO superviseUser);
    int deleteDOById(Long id);
    int deleteDOByIds(String[] ids);

    @Select({"<script>",
            "   select count(1) from supervise_user",
            "   <where>",
            "       deleted=0",
            "       <if test=\"param.username!=null and param.username!=''\">and username=#{param.username}</if>",
            "   </where>",
            "</script>"})
    long pageCount(@Param("param") SuperviseUserRequest param);
    @Select({"<script>",
            "   select * from supervise_user",
            "   <where>",
            "       deleted=0",
            "       <if test=\"param.username!=null and param.username!=''\">and username=#{param.username}</if>",
            "   </where>",
            "   order by create_time desc limit #{limit} offset #{offset}",
            "</script>"})
    List<SuperviseUserDO> pageQuery(@Param("param") SuperviseUserRequest param, @Param("limit") int limit, @Param("offset") long offset);

    List<String> selectAllAccount();

}
